<?php
declare(strict_types=1);
/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://gitee.com/xmo/MineAdmin
 */
namespace Plugin\File\Http\Request\Admin;

use Hyperf\Validation\Request\FormRequest;

/**
 * 音频验证数据类
 */
class RdFileVoiceRequest extends FormRequest
{

    /**
     * 场景配置
     */
    protected array $scenes = [
        'index' => [
            'type',
            'created_at',
            'updated_at',
        ],
        'create' => [
            'type',
            'text',
        ],
        'update' => [
            'type',
            'text',
        ]
    ];

    public function authorize(): bool
    {
        return true;
    }


    /**
     * 新增数据验证规则
     * return array
     */
    public function rules(): array
    {
        return [
            'file' => 'string|max:255',
            'text' => 'string',
            'type' => 'integer|in:1,2,3', // 限制类型只能是1,2,3
        ];
    }


    /**
     * 字段映射名称
     * return array
     */
    public function attributes(): array
    {
        return [
            'id' => '主键',
            'file' => '音频地址',
            'type' => '音频类型', // 1-摄像头名称，2-预警事件，3-遵守文本

        ];
    }

public function messages(): array
{
    return [
            'id.required' => '必填',
            'file.required' => '必填音频地址',
            'type.required' => '必填音频类型',
            'type.in' => '音频类型只能是1(摄像头名称)、2(预警事件)或3(遵守文本)',

    ];
}
}